﻿using System;
using System.Windows;
using Csla.Xaml;
using HeThongThongTin.Library;

namespace HeThongThongTin.UI.SL.DanhMuc.DM_Table
{
    public partial class DM_Table_ListViewModel : ViewModel<DM_TableList>
    {

        public DM_Table_ListViewModel(string mode)
        {
            BeginRefresh("GetDM_TableList", mode);

        }
        
        
        public void GetDM_Table_ListViewModel(string mode)
        {
            BeginRefresh("GetDM_TableList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(DM_TableInfo), typeof(DM_Table_ListViewModel), null);
        public DM_TableInfo SelectedItem
        {
            get { return (DM_TableInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteDM_Table(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                HeThongThongTin.Library.DM_Table.DeleteDM_Table(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetDM_TableList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
